/**
 * Created by imac13 on 19/1/4.
 */
import React from 'react';
import { Select } from 'antd'
const Option = Select.Option;
export default {
    formateDate (time) {
        if (!time) return '';
        let nowTime = new Date(time);
        let year = nowTime.getFullYear();
        let month = nowTime.getMonth()+1;
        let date = nowTime.getDate();
        let hour = nowTime.getHours();
        let minutes = nowTime.getMinutes();
        let second = nowTime.getSeconds();

        return year + '-' + month + '-' + date + ' ' + hour + ':' + minutes + ':' + second
    },

    pagination (data,callback) {
        return {
            onChange:(current)=>{
                callback(current)
            },
            current:data.result.page,
            pageSize:data.result.page_size,
            total:data.result.total_count,
            showTotal:()=>{
                return `共${data.result.total_count}条`
            },
            showQuickJumper:true,
        }

    },

    getOptionList(data){
        if(!data){
            return [];
        }
        let options = [];
        data.map((item)=>{
            options.push(<Option value={item.id} key={item.id}>{item.name}</Option>)
        });
        return options;
    },

}